import React, { Component } from 'react'
import { connect } from 'dva';
import FormList from '../components/FormItem';
import { EDIT_KEYS } from '../enum';
import { UmiComponentProps, BaseComponentProps } from '@/common/type';

interface P {
  data?: {
    id: any,
    buildId?: any,
    floorId?: any,
    areaId?: any,
    brandId?: any,
    productId?: any,
    floorPlanX?: any,
    floorPlanY?: any,
    brandName?: string,
    productName?: string,
    buildName?: string, floorName?: string, areaName?: string,
  };
  match: any;
  details: object;
}

type Props = P & UmiComponentProps & BaseComponentProps;

@connect(({ device_fire_monitor }) => ({
  data: device_fire_monitor.editDetails
}))
class Update extends Component<Props> {

  componentDidMount() {
    const { dispatch, match } = this.props;
    const { params } = match;

    dispatch({
      type: 'device_fire_monitor/queryEditInfoById',
      payload: {
        id: params.id,
        keys: EDIT_KEYS
      }
    })
  }

  render() {
    return (
      <section className="edit">
        <FormList data={this.props.data} key={Date.now()}/>
      </section>
    );
  }
}

export default Update;
